import QtQuick 2.12
import QtQuick.Controls 2.12


Switch {
    id:control
    implicitWidth: 48
    implicitHeight: 26
    display:AbstractButton.TextBesideIcon


    contentItem: Text {
        text: control.text
        font: control.font
        opacity: enabled ? 1.0 : 0.3
        color: control.down ? "#17a81a" : "#21be2b"
        //leftPadding: control.indicator.width + control.spacing + 6
        leftPadding: control.width
        verticalAlignment: Text.AlignVCenter
    }

    indicator:Rectangle {
        x: control.visualPosition * (control.width - width)
        y: (control.height - height) / 2
        width: 26
        height: 26

        radius: 13
        color: control.down ? "#00ffff" : "white"
        border.color: !control.checked ? "#999999"
                                       : (control.down ? "#00ffff" : "white")

        Behavior on x {
            enabled: !control.pressed
            SmoothedAnimation { velocity: 200 }
        }
    }
    background: Rectangle {
        radius: 13
        color: control.checked ? "#3fa2f3" : "gray"
        border.color: control.checked ? "#3fa2f3" : "gray"
    }

}
